<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>9090分销管理平台</title>
    <jsp:include page="${pageContext.request.contextPath}/include/include.jsp"></jsp:include>
    <c:if test="${setting.flColorTheme != null && setting.flColorTheme != ''}">
        <link id="theme" href="${pageContext.request.contextPath}${setting.flColorTheme}" rel="stylesheet">
    </c:if>
    <script src="${pageContext.request.contextPath}/common/js/demo/nifty-demo.js"></script>
    <script src="${pageContext.request.contextPath}/common/plugins/morris-js/morris.min.js"></script>
    <script src="${pageContext.request.contextPath}/common/plugins/morris-js/raphael-js/raphael.min.js"></script>
    <script src="${pageContext.request.contextPath}/common/plugins/sparkline/jquery.sparkline.min.js"></script>
</head>
<body>
<div id="container" class="
	    	<c:if test='${setting.flBoxLay==1}'> boxed-layout </c:if>
	    	<c:if test='${setting.flAnimate==1}'> effect ${setting.flAnimateType}</c:if>
	    	<c:if test='${setting.flFixedNavbar==1}'> navbar-fixed </c:if>
	    	<c:if test='${setting.flFixedFooter==1}'> footer-fixed </c:if>
	    	<c:if test='${setting.flFixedNav==1}'> mainnav-fixed </c:if>
	    	<c:if test='${setting.flShowAsd==1}'> aside-in </c:if>
	    	<c:if test='${setting.flFixedAsd==1}'> aside-fixed </c:if>
	    	<c:if test='${setting.flLeftAsd==1}'> aside-left </c:if>
	    	<c:if test='${setting.flFloatAsd==1}'> aside-float </c:if>
	    	<c:if test='${setting.flDarkAsd==0}'> aside-bright </c:if>
	    	<c:choose><c:when test='${setting.flNavColl==1}'>mainnav-sm</c:when><c:otherwise>mainnav-lg</c:otherwise></c:choose> ">

    <jsp:include page="${pageContext.request.contextPath}/include/header.jsp"></jsp:include>
    <div class="boxed">
        <div id="content-container">
            <jsp:include page="${pageContext.request.contextPath}/include/main.jsp"></jsp:include>
        </div>
        <jsp:include page="${pageContext.request.contextPath}/include/aside.jsp"></jsp:include>
        <jsp:include page="${pageContext.request.contextPath}/include/nav.jsp"></jsp:include>
    </div>
    <jsp:include page="${pageContext.request.contextPath}/include/footer.jsp"></jsp:include>
    <button class="scroll-top btn">
        <i class="pci-chevron chevron-up"></i>
    </button>

    <div id="homeDetail" class="modal fade bs-modal-sm in" tabindex="-1" role="dialog" aria-hidden="false"
         style="display: none;">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title">修改密码</h4>
                </div>
                <div class="modal-body">
                    <form id="updatePwdForm" role="form" class="form-horizontal parsley-form" data-parsley-validate=""
                          method="post">
                        <div class="row" style="padding-top: 10px;">
                            <div class="col-lg-12">
                                <div class="form">
                                    <label for="oldPassword" class="col-sm-2 control-label">原密码</label>
                                    <div class="col-sm-8">
                                        <input id="oldPassword" tabindex="1" type="password" class="form-control"
                                               name="old_pwd" data-parsley-required="true" placeholder="原密码">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row" style="padding-top: 10px;">
                            <div class="col-lg-12">
                                <div class="form">
                                    <label for="newPassword" class="col-sm-2 control-label">新密码</label>
                                    <div class="col-sm-8">
                                        <input id="newPassword" tabindex="2" type="password" class="form-control"
                                               name="new_pwd" data-parsley-required="true" data-parsley-minlength="6"
                                               data-parsley-maxlength="20" placeholder="新密码">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row" style="padding-top: 10px;">
                            <div class="col-lg-12">
                                <div class="form">
                                    <label for="passwordAgain" class="col-sm-2 control-label">确认密码</label>
                                    <div class="col-sm-8">
                                        <input id="passwordAgain" type="password" tabindex="6" class="form-control"
                                               name="password2" placeholder="确认密码">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取 消</button>
                    <button type="button" id="okPwd" class="btn btn-primary">确 认</button>
                </div>
                <script type="text/javascript">
                    $(function () {
                        $("#okPwd").on("click",function(){
                            $("#updatePwdForm").submit();
                        });
                        validPassword = {
                            notEmpty: {
                                message: '*密码不能为空'
                            },
                            stringLength: {
                                max: 15,
                                message: '*密码长度必须小于15'
                            }
                        };
                        validPassword2 = {
                            notEmpty: {
                                message: '密码不能为空'
                            },
                            stringLength: {
                                max: 15,
                                message: '*确认密码长度必须小于15'
                            },
                            identical: {
                                field: 'new_pwd',
                                message: '*两次输入密码不一致'
                            }
                        };

                        function save() {
                            var data = common_ajax.ajaxFunc(ctx + "/sysUser/updatePwd", $('#updatePwdForm').serialize(), "json", null);
                            if (data.code === 0) {
                                pointLion.alertMsg(data.msg, "success", "small", function () {
                                    $('#homeDetail').modal('hide');
                                });
                            } else {
                                pointLion.alertMsg(data.msg, "danger", "small", function () {
                                });
                            }
                        }


                        $(document).ready(function () {
                            $('#updatePwdForm').bootstrapValidator({
                                excluded: [":hidden"],//关键配置，表示只对于隐藏域不进行验证，其他的表单元素都要验证
                                fields: {
                                    "old_pwd": {
                                        validators: {
                                            notEmpty: {
                                                message: '*请输入旧密码'
                                            }
                                        }
                                    },

                                    "new_pwd": {
                                        validators: validPassword
                                    },
                                    "password2": {
                                        validators: validPassword2
                                    }
                                }
                            }).on("success.form.bv", function (e) {
                                save();
                                return false;//阻止表单跳转
                            });
                        });
                    });
                </script>
            </div>
        </div>
    </div>

</div>
<jsp:include page="${pageContext.request.contextPath}/include/setting.jsp"></jsp:include>
<script>
    //PJax
    function doPjax(url) {
        $(document).on('pjax:start', function () {
            history.replaceState({}, "", ctx + "/sysUser/index");
        });
        $(document).on('pjax:end', function () {
            history.replaceState({}, "", ctx + "/sysUser/index");
        });
        $.pjax({'url': url, container: '#content-container', timeout: 999999});
    }

    //PJax-可传递容器
    function doPjaxC(url, container) {
        $(document).on('pjax:start', function () {
            history.replaceState({}, "", ctx + "/sysUser/index");
        });
        $(document).on('pjax:end', function () {
            history.replaceState({}, "", ctx + "/sysUser/index");
        });
        $.pjax({'url': url, 'container': container, timeout: 999999});
    }


    //初始化高度
    function initFullHeight() {
        var clientW = document.body.clientHeight - 160;
        $(".lion-fullHeight").css("min-height", clientW + "px");
    }

</script>
</body>
</html>
